import javafx.scene.chart.Chart;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author Koizumi Sinya
 * @date 2018/02/09. 11:18
 * @edithor
 * @date
 */
public class Main {

    public static void main(String[] args) {
//        String input = "Cv 79 agctu gh cig, vjg yknn tgkipu; cv 69, vjg ykv; cpf cv 59, vjg lwfiogpv.";
//        String input = "At 20 years of age, the will reigns; at 30, the wit; and at 40, the judgment.";
//        String result = testEncryption(input);
//        System.out.println(result);
        test1();
    }

    public static void test1() {
        System.out.println("" + calculateDpi(1280, 752, 8.9));
    }

    public static double calculateDpi(int width, int height, double inch) {
        double diagonal = Math.sqrt(width * width + height * height);
        return diagonal / inch / 160;
    }

    public static String testEncryption(String input) {
        String outPut;

        HashMap<String, String> letterMap = new HashMap<>();
        HashMap<Integer, Integer> numberMap = new HashMap<>();

        for (int i = 0; i < 26; i++) {
            String key = String.format("%c", 'a' + i);
            String value;
            if ("y".equals(key)) {
                value = "a";
            } else if ("z".equals(key)) {
                value = "b";
            } else {
                value = String.format("%c", 'c' + i);
            }
            //System.out.println("key = " + key + "; value = " + value);
            letterMap.put(key, value);
        }
        System.out.println(letterMap.toString());

        for (int i = 0; i <= 8; i++) {
            numberMap.put(i + 1, 8 - i);
        }

        System.out.println(numberMap.toString());

        char[] arr = input.toLowerCase().toCharArray();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < arr.length; i++) {
            char temp = arr[i];
            if (temp >= 'a' && temp <= 'z') {
                String key = String.valueOf(temp);
                if (letterMap.containsKey(key)) {
                    builder.append(letterMap.get(key));
                }
            } else if (temp >= '0' && temp <= '9') {
                int key = Integer.valueOf(String.valueOf(temp));
                if (numberMap.containsKey(key)) {
                    builder.append(String.valueOf(numberMap.get(key)));
                }
            } else {
                builder.append(String.valueOf(temp));
            }


        }
        outPut = builder.toString();

        return outPut;
    }
}
